<template>
	<view class="mainbgc" v-if="pageShow">
		<header-top :messageInfo="{typeFlag:false,message:'工作台',liner:false}">
			<view class="rightmsg" slot="rightmsg">
				<view class="rightmsg_content flexcolumn" @click="jumpdetail">
					<!-- <view class="gongzuotai"></view> -->
					<view class="nostrongtext">编辑</view>
				</view>
			</view>
		</header-top>
		<view class="tabbarpad">
			<!-- 基本资料 -->
			<view class="strongtext margin_top" v-if="informationstate">
				<text class="titletext textliner">基本资料</text>
			</view>
			<view class="ffffff radius bigbox flexstart margin_top" v-if="informationstate">
				<view class="itembox margin_top" v-show="item.state" v-for="(item,index) in information" :key="index"
					@click="jumpurl(item.url,item.id)">
					<view class="flexcolumn">
						<view class="workimage">
							<image :src="item.Image" mode=""></image>
						</view>
						<view class="worktext">{{item.text}}</view>
					</view>
				</view>
			</view>
			<!-- 采购管理 -->
			<view class="strongtext margin_top" v-if="supplyinfostate">
				<text class="titletext textliner">采购管理</text>
			</view>
			<view class="ffffff radius bigbox flexstart margin_top" v-if="supplyinfostate">
				<view class="itembox margin_top" v-show="item.state" v-for="(item,index) in supplyinfo" :key="index"
					@click="jumpurl(item.url,item.id)">
					<view class="flexcolumn">
						<view class="workimage">
							<image :src="item.Image" mode=""></image>
						</view>
						<view class="worktext">{{item.text}}</view>
					</view>
				</view>
			</view>
			<!-- 销售管理 -->
			<view class="strongtext margin_top" v-if="salesinfostate">
				<text class="titletext textliner">销售管理</text>
			</view>
			<view class="ffffff radius bigbox flexstart margin_top" v-if="salesinfostate">
				<view class="itembox margin_top" v-show="item.state" v-for="(item,index) in salesinfo" :key="index"
					@click="jumpurl(item.url,item.id)">
					<view class="flexcolumn">
						<view class="workimage">
							<image :src="item.Image" mode=""></image>
						</view>
						<view class="worktext">{{item.text}}</view>
					</view>
				</view>
			</view>
			<!-- 考勤管理 -->
			<view class="strongtext margin_top" v-if="kaoqinglstate">
				<text class="titletext textliner">考勤管理</text>
			</view>
			<view class="ffffff radius bigbox flexstart margin_top" v-if="kaoqinglstate">
				<view class="itembox margin_top" v-show="item.state" v-for="(item,index) in kaoqingl" :key="index"
					@click="jumpurl(item.url,item.id)">
					<view class="flexcolumn">
						<view class="workimage">
							<image :src="item.Image" mode=""></image>
						</view>
						<view class="worktext">{{item.text}}</view>
					</view>
				</view>
			</view>
			<!-- 库存管理 -->
			<view class="strongtext margin_top" v-if="Inventoryinfostate">
				<text class="titletext textliner">库存管理</text>
			</view>
			<view class="ffffff radius bigbox flexstart margin_top" v-if="Inventoryinfostate">
				<view class="itembox margin_top" v-show="item.state" v-for="(item,index) in Inventoryinfo" :key="index"
					@click="jumpurl(item.url,item.id)">
					<view class="flexcolumn">
						<view class="workimage">
							<image :src="item.Image" mode=""></image>
						</view>
						<view class="worktext">{{item.text}}</view>
					</view>
				</view>
			</view>
			<!-- 财务管理 -->
			<view class="strongtext margin_top" v-if="financialinfostate">
				<text class="titletext textliner">财务管理</text>
			</view>
			<view class="ffffff radius bigbox flexstart margin_top" v-if="financialinfostate">
				<view class="itembox margin_top" v-show="item.state" v-for="(item,index) in financialinfo" :key="index"
					@click="jumpurl(item.url,item.id)">
					<view class="flexcolumn">
						<view class="workimage">
							<image :src="item.Image" mode=""></image>
						</view>
						<view class="worktext">{{item.text}}</view>
					</view>
				</view>
			</view>
			<!-- 经营分析 -->
			<view class="strongtext margin_top" v-if="analysisstate">
				<text class="titletext textliner">经营分析</text>
			</view>
			<view class="ffffff radius bigbox flexstart margin_top" v-if="analysisstate">
				<view class="itembox margin_top" v-show="item.state" v-for="(item,index)  in analysis" :key="index"
					@click="jumpurl(item.url,item.id)">
					<view class="flexcolumn">
						<view class="workimage">
							<image :src="item.Image" mode=""></image>
						</view>
						<view class="worktext">{{item.text}}</view>
					</view>
				</view>
			</view>
		</view>
		<u-modal :show="bfzshow" title="提示" content='系统检测到您当前存在拜访的客户,如需进入拜访任务需放弃当前拜访或完成拜访' cancelText='取消'
			confirmText='确定' :showCancelButton='true' @confirm="confirm()" @cancel="bfzshow=false"></u-modal>
		<tabbar current=2></tabbar>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				bfzshow: false,
				// 基本资料
				information: [{
						id: 5,
						Image: require('../../static/image/office/jb3.png'),
						url: "/pages/workbench/jiben/kehuda",
						text: "客户档案",
						state: true
					}, {
						id: 18,
						Image: require('../../static/image/office/jb1.png'),
						url: "/pages/workbench/jiben/shangpinda",
						text: "商品档案",
						state: true
					},
					{
						id: 10,
						Image: require('../../static/image/office/jb2.png'),
						url: "/pages/workbench/jiben/gongyingsda",
						text: "供应商档案",
						state: true
					},
					{
						id: 1,
						Image: require('../../static/image/office/jb4.png'),
						url: "/pages/workbench/jiben/yuangongda",
						text: "员工档案",
						state: true
					},
					{
						id: 14,
						Image: require('../../static/image/office/jb5.png'),
						url: "/pages/workbench/jiben/cangkuda",
						text: "仓库档案",
						state: true
					}
				],
				// 采购管理
				supplyinfo: [{
						id: 22,
						Image: require('../../static/image/office/cg1.png'),
						url: "/pages/workbench/caigou/caigoudan",
						text: "采购单",
						state: true
					},
					{
						id: 23,
						Image: require('../../static/image/office/cg2.png'),
						url: "/pages/workbench/caigou/caigoudcx",
						text: "采购单查询",
						state: true
					},
					{
						id: 29,
						Image: require('../../static/image/office/cg7.png'),
						url: "/pages/workbench/caigou/caigouthd",
						text: "采购退货单",
						state: true
					},
					{
						id: 30,
						Image: require('../../static/image/office/cg3.png'),
						url: "/pages/workbench/caigou/caigouthdcx",
						text: "采购退货单查询",
						state: true
					},
				],
				// 销售管理
				salesinfo: [{
						id: 36,
						Image: require('../../static/image/office/xs2.png'),
						url: "/pages/workbench/xiaoshou/xiaoshoudd",
						text: "销售单",
						state: true
					},
					{
						id: 37,
						Image: require('../../static/image/office/xs1.png'),
						url: "/pages/workbench/xiaoshou/xiaoshouddcx",
						text: "销售单查询",
						state: true
					},
					{
						id: 45,
						Image: require('../../static/image/office/xs3.png'),
						url: "/pages/workbench/xiaoshou/tuihuodan",
						text: "销售退货单",
						state: true
					},
					{
						id: 46,
						Image: require('../../static/image/office/xs4.png'),
						url: "/pages/workbench/xiaoshou/tuihuodcx",
						text: "销售退货单查询",
						state: true
					},
					{
						id: 52,
						Image: require('../../static/image/office/xs5.png'),
						url: "/pages/workbench/xiaoshou/fujinkh",
						text: "客户拜访",
						state: true
					},
					{
						id: 15,
						Image: require('../../static/image/office/xs6.png'),
						url: "/pages/homepage/news/baifangdetail",
						text: "拜访任务",
						state: true
					},
					{
						id: 55,
						Image: require('../../static/image/office/xs7.png'),
						url: "/pages/homepage/news/kehuls",
						text: "客户预警",
						state: true
					},
					{
						id: 59,
						Image: require('../../static/image/office/xs19.png'),
						url: "/pages/workbench/xiaoshou/sijisongh",
						text: "司机配送",
						state: true
					}
				],
				// 考勤管理
				kaoqingl: [{
						id: 130,
						Image: require('../../static/image/office/xs13.png'),
						url: "/pages/workbench/xiaoshou/kaoqinsz",
						text: "考勤设置",
						state: true
					},
					{
						id: 87,
						Image: require('../../static/image/office/xs13.png'),
						url: "/pages/workbench/xiaoshou/waiqinguiji",
						text: "外勤轨迹",
						state: true
					},
					{
						id: 88,
						Image: require('../../static/image/office/xs14.png'),
						url: "/pages/workbench/xiaoshou/yewuybfjl",
						text: "业务员拜访记录",
						state: true
					},
					{
						id: 89,
						Image: require('../../static/image/office/xs16.png'),
						url: "/pages/workbench/xiaoshou/kaoqindk",
						text: "考勤打卡",
						state: true
					},
					{
						id: 90,
						Image: require('../../static/image/office/xs17.png'),
						url: "/pages/workbench/xiaoshou/wodekq",
						text: "我的考勤",
						state: true
					},
					{
						id: 92,
						Image: require('../../static/image/office/xs18.png'),
						url: "/pages/workbench/xiaoshou/kaoqinqj",
						text: "考勤请假",
						state: true
					},
					{
						id: 91,
						Image: require('../../static/image/office/xs20.png'),
						url: "/pages/workbench/xiaoshou/kaoqinsx",
						text: "考勤统计",
						state: true
					},
				],
				// 库存管理
				Inventoryinfo: [{
						id: 93,
						Image: require('../../static/image/office/kc2.png'),
						url: "/pages/workbench/kucun/kucundiaobo",
						text: "库存调拨",
						state: true
					},
					{
						id: 94,
						Image: require('../../static/image/office/kc1.png'),
						url: "/pages/workbench/kucun/kucundbcx",
						text: "库存调拨查询",
						state: true
					},
					{
						id: 97,
						Image: require('../../static/image/office/kc3.png'),
						url: "/pages/homepage/news/kucun",
						text: "仓库预警",
						state: true
					},
					{
						id: 98,
						Image: require('../../static/image/office/kc4.png'),
						url: "/pages/workbench/kucun/kucunchax",
						text: "库存查询",
						state: true
					},
					{
						id: 100,
						Image: require('../../static/image/office/kc5.png'),
						url: "/pages/workbench/kucun/kucunpd",
						text: "库存盘点",
						state: true
					},
					{
						id: 101,
						Image: require('../../static/image/office/kc6.png'),
						url: "/pages/workbench/kucun/pandiandmxcx",
						text: "盘点单明细查询",
						state: true
					},
					{
						id: 103,
						Image: require('../../static/image/office/kc7.png'),
						url: "/pages/workbench/kucun/rukud",
						text: "入库单",
						state: true
					},
					{
						id: 104,
						Image: require('../../static/image/office/kc8.png'),
						url: "/pages/workbench/kucun/rukudancx",
						text: "入库单查询",
						state: true
					},
					{
						id: 110,
						Image: require('../../static/image/office/cg6.png'),
						url: "/pages/workbench/kucun/chukud",
						text: "出库单",
						state: true
					},
					{
						id: 111,
						Image: require('../../static/image/office/kc8.png'),
						url: "/pages/workbench/kucun/chukudancx",
						text: "出库单查询",
						state: true
					}
				],
				// 财务管理
				financialinfo: [{
						id: 126,
						Image: require('../../static/image/office/jy10.png'),
						url: "/pages/workbench/caiwu/yingshouk",
						text: "应收款",
						state: true
					},{
						id: 73,
						Image: require('../../static/image/office/kh1.png'),
						url: "/pages/workbench/caiwu/kehuysk",
						text: "客户预收款",
						state: true
					},
					{
						id: 76,
						Image: require('../../static/image/office/kh3.png'),
						url: "/pages/workbench/caiwu/kehuyskcx",
						text: "客户预收款查询",
						state: true
					},
					{
						id: 72,
						Image: require('../../static/image/office/kh2.png'),
						url: "/pages/workbench/caiwu/kehujs",
						text: "客户欠款结算",
						state: true
					},
					{
						id: 74,
						Image: require('../../static/image/office/kh3.png'),
						url: "/pages/workbench/caiwu/kehuqkcx",
						text: "欠款结算查询",
						state: true
					},
					{
						id: 77,
						Image: require('../../static/image/office/kh8.png'),
						url: "/pages/workbench/caiwu/gongyingsjs",
						text: "供应商结算",
						state: true
					},
					{
						id: 78,
						Image: require('../../static/image/office/kh9.png'),
						url: "/pages/workbench/caiwu/gongyingscx",
						text: "供应商结算查询",
						state: true
					},
					{
						id: 79,
						Image: require('../../static/image/office/kh5.png'),
						url: "/pages/workbench/caiwu/feiyongzc",
						text: "费用支出",
						state: true
					},
					{
						id: 80,
						Image: require('../../static/image/office/kh5.png'),
						url: "/pages/workbench/caiwu/feiyongcx",
						text: "费用查询",
						state: true
					},
					{
						id: 125,
						Image: require('../../static/image/office/kh6.png'),
						url: "/pages/workbench/caiwu/shouzhangdz",
						text: "收款对账",
						state: true
					},
					{
						id: 131,
						Image: require('../../static/image/office/kh6.png'),
						url: "/pages/workbench/caiwu/huokuanjz",
						text: "货款交账",
						state: true
					},
					{
						id: 133,
						Image: require('../../static/image/office/kh6.png'),
						url: "/pages/workbench/caiwu/shoukuanmx",
						text: "收货款明细",
						state: true
					},
					{
						id: 85,
						Image: require('../../static/image/office/kh7.png'),
						url: "/pages/workbench/caiwu/yuangongsr",
						text: "员工收入",
						state: true
					},
					{
						id: 86,
						Image: require('../../static/image/office/kh7.png'),
						url: "/pages/workbench/caiwu/jingyingzk",
						text: "经营状况",
						state: true
					}
				],
				// 经营分析
				analysis: [{
						id: 117,
						Image: require('../../static/image/office/jy1.png'),
						url: "/pages/workbench/jingying/kehupaihangb",
						text: "客户排行榜",
						state: true
					},
					{
						id: 118,
						Image: require('../../static/image/office/jy2.png'),
						url: "/pages/workbench/jingying/yewuphb",
						text: "业务销售排行榜",
						state: true
					},
					{
						id: 119,
						Image: require('../../static/image/office/jy3.png'),
						url: "/pages/workbench/jingying/rexiaophb",
						text: "热销排行榜",
						state: true
					},
					{
						id: 120,
						Image: require('../../static/image/office/jy5.png'),
						url: "/pages/workbench/jingying/kucunzxbb",
						text: "库存滞销报表",
						state: true
					},
					{
						id: 121,
						Image: require('../../static/image/office/jy6.png'),
						url: "/pages/workbench/jingying/kehubffx",
						text: "客户拜访分析",
						state: true
					},
					{
						id: 122,
						Image: require('../../static/image/office/jy7.png'),
						url: "/pages/workbench/jingying/xiaoshoulrph",
						text: "销售利润排行",
						state: true
					},
					{
						id: 123,
						Image: require('../../static/image/office/jy8.png'),
						url: "/pages/workbench/jingying/xinzengkhfx",
						text: "新增客户分析",
						state: true
					},
					{
						id: 124,
						Image: require('../../static/image/office/jy10.png'),
						url: "/pages/workbench/jingying/xiaoshouefx",
						text: "销售额分析",
						state: true
					}
				],
				informationstate: true, //是否存在为true的情况
				supplyinfostate: true,
				salesinfostate: true,
				kaoqinglstate: true,
				Inventoryinfostate: true,
				financialinfostate: true,
				analysisstate: true,
				pageShow: false
			}
		},
		onLoad() {
			uni.hideTabBar(); //隐藏tab

		},
		onShow() {
			this.pageShow = false
			if (uni.getStorageSync("information")) { // 基本资料
				this.information = JSON.parse(uni.getStorageSync("information"))
				let num = 0
				this.information.forEach(item => {
					if (item.state) num++ 
				})
				if (num == 0) this.informationstate = false
				if (num != 0) this.informationstate = true

			} else {
				uni.setStorageSync("information", JSON.stringify(this.information))
			}
			if (uni.getStorageSync("supplyinfo")) { // 采购管理
				this.supplyinfo = JSON.parse(uni.getStorageSync("supplyinfo"))
				let num = 0
				this.supplyinfo.forEach(item => {
					if (item.state) num++
				})
				if (num == 0) this.supplyinfostate = false
				if (num != 0) this.supplyinfostate = true
			} else {
				uni.setStorageSync("supplyinfo", JSON.stringify(this.supplyinfo))
			}
			if (uni.getStorageSync("salesinfo")) { // 销售管理
				this.salesinfo = JSON.parse(uni.getStorageSync("salesinfo"))
				let num = 0
				this.salesinfo.forEach(item => {
					if (item.state) num++
				})
				if (num == 0) this.salesinfostate = false
				if (num != 0) this.salesinfostate = true
			} else {
				uni.setStorageSync("salesinfo", JSON.stringify(this.salesinfo))
			}
			if (uni.getStorageSync("kaoqingl")) { // 考勤管理
				this.kaoqingl = JSON.parse(uni.getStorageSync("kaoqingl"))
				let num = 0
				this.kaoqingl.forEach(item => {
					if (item.state) num++
				})
				if (num == 0) this.kaoqinglstate = false
				if (num != 0) this.kaoqinglstate = true
			} else {
				uni.setStorageSync("kaoqingl", JSON.stringify(this.kaoqingl))
			}
			if (uni.getStorageSync("Inventoryinfo")) { // 财务管理
				this.Inventoryinfo = JSON.parse(uni.getStorageSync("Inventoryinfo"))
				let num = 0
				this.Inventoryinfo.forEach(item => {
					if (item.state) num++
				})
				if (num == 0) this.Inventoryinfostate = false
				if (num != 0) this.Inventoryinfostate = true
			} else {
				uni.setStorageSync("Inventoryinfo", JSON.stringify(this.Inventoryinfo))
			}
			if (uni.getStorageSync("financialinfo")) { // 财务管理
				this.financialinfo = JSON.parse(uni.getStorageSync("financialinfo"))
				let num = 0
				this.financialinfo.forEach(item => {
					if (item.state) num++
				})
				if (num == 0) this.financialinfostate = false
				if (num != 0) this.financialinfostate = true
			} else {
				uni.setStorageSync("financialinfo", JSON.stringify(this.financialinfo))
			}
			if (uni.getStorageSync("analysis")) { // 经营分析
				this.analysis = JSON.parse(uni.getStorageSync("analysis"))
				let num = 0
				this.analysis.forEach(item => {
					if (item.state) num++
				})
				if (num == 0) this.analysisstate = false
				if (num != 0) this.analysisstate = true
			} else {
				uni.setStorageSync("analysis", JSON.stringify(this.analysis))
			}
			this.pageShow = true
		},
		methods: {
			userxinxi() {
				httpRequest.request('appapi/manage/user/info', 'POST', {}, false, false, true).then(res => {
					if (res.code == 1) {
						this.$store.state.userInfo = res.data
					}
				})
			},
			jumpurl(url, qxpdid) {
				if (!httpRequest.qxpd(qxpdid, this.$store.state.userInfo.ability_rule_ids)) {
					return false
				}
				uni.navigateTo({
					url: url
				})
			},
			jumpdetail() {
				uni.navigateTo({
					url: '/pages/workbench/workbenchdetail'
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.bigbox {
		flex-wrap: wrap;
		padding: 0 10rpx 30rpx 10rpx;
	}

	.itembox {
		width: 33.33%;
	}

	.workimage {
		width: 110rpx;
		height: 110rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.worktext {

		font-size: 32rpx;
		font-family: PingFang SC-Medium, PingFang SC;
		font-weight: 500;
		color: #333333;
		text-align: center;
	}

	.tabbarpad {
		padding: 0 30rpx 160rpx 30rpx;
	}
</style>